<?php

namespace App\Models\Admin;

use App\Tools\Financial;
use App\Tools\Prstatic;

use Illuminate\Database\Eloquent\Model;

class StoreGoodsRepertoryLog extends Model
{

    protected $table = 'store_goods_repertory_log';
    protected $primaryKey = 'id';
    protected $dateFormat = 'U';
    protected $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s'
    ];

    /**
     * 添加库存变动日志
     * @param $order_id
     * @param $goods_id
     * @param $goods_num
     * @param int $store_id
     * @param int $type
     * @param string $create_user
     * @return bool
     */
    public static function addInfoByGoodsId($order_id, $goods_id, $goods_num, $store_id = 0, $type = 1, $create_user = '', $money = 0)
    {
        $info['store_id'] = $store_id;
        $info['order_id'] = $order_id;
        $info['goods_id'] = $goods_id;
        $info['goods_num'] = $goods_num;
        $info['goods_money'] = $money;
        $info['type'] = $type;
        $info['created_at'] = time();
        $info['create_user'] = $create_user;
        return self::insert(array_filter($info));
        return true;
    }
}